import { legacy_createStore, combineReducers, applyMiddleware } from "redux";
import Num from "./module/num.js";
import Arr from "./module/arr.js";
import Loading from "./module/loading.js";
/**
 * 思路1、循环判断 action.type 和 action.actionNames中是否一致
 * 思路2、直接判断模块中的action中是否有action[action.type]这个方法，有就调用
 */

/**
 * redux本身自带的模块化
 * 1、使用combineReducers来创建一个 reducers
 * 2、使用legacy_createStore将reducers创建一个仓库
 */
const reducers = combineReducers({
  Num,
  Arr,
  Loading,
});

// const store = legacy_createStore(reducers);//同步写法

/**
 * 使用redux-thunk实现异步
 */
import thunk from "redux-thunk";

const store = legacy_createStore(reducers, applyMiddleware(thunk));

export default store;
